package com.example.demo.controller;

import com.auntvt.timo.jpax.core.quick.matcher.QuickMatcher;
import com.auntvt.timo.jpax.core.quick.model.Matcher;
import com.auntvt.timo.jpax.springbootstarter.helper.PageHelper;
import com.example.demo.domain.Order;
import com.example.demo.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 小懒虫 <auntvt@163.com>
 * @date 2021/7/31
 */
@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    OrderService orderService;

    @GetMapping("/pages")
    public Page<Order> pages(Matcher<Order> matcher) {

        QuickMatcher<Order> quickMatcher = new QuickMatcher<>(matcher);
        return orderService.pages(quickMatcher, PageHelper.pageRequest("id"));
    }
}
